<template>
  <el-dialog :title="title" :visible.sync="visible" width="40%">
    <el-form
      :model="dataForm"
      label-width="150px"
      :rules="rules"
      ref="addEditRef"
    >
      <el-form-item label="表格内容：">
        <span>就是一个内容</span>
      </el-form-item>
    </el-form>

    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false" size="small">取 消</el-button>
      <el-button
        type="primary"
        @click="handleSave"
        :loading="saveBtnLoading"
        size="small"
      >
        保 存
      </el-button>
    </span>
  </el-dialog>
</template>


<script>
export default {
  name: "AddEditDialog",
  data() {
    return {
      title: "模板弹框",
      visible: false,
      dataForm: {},
      rules: {},

      saveBtnLoading: false,
    };
  },
  methods: {
    init(options) {
      const {} = options;
      this.visible = true;
    },
    handleSave() {
      this.saveBtnLoading = true;
      this.$refs["addEditRef"].validate(async (valid) => {
        if (valid) {
          // TODO...
          this.saveBtnLoading = false;
        } else {
          this.saveBtnLoading = false;
        }
      });
    },
  },
};
</script>